CSCI 131,
Fall 2003,
Test 2.
- The weight of each question is given with the question
- Use as much paper as you wish, but make your answers are legible.
- Please answer each question thoughtfully and carefully.
- [5 pts] Define Abstract Data Type.
- [5 pts] The complexity of an algorithm is a measure of the effort
expended in performing a computation, (often expressed
as O(f(n)), as in O(n), or O(n2). Give pseudo code
for an O(n) algorithm to find an item in an array. Why is this
algorithm O(n).
- [5 pts] What is a class constructor? When and how is a constructor
invoked? Why is a facility for a constructor provided?
- [5 pts] What does it mean to overload a function? Give an example.
- [5 pts] Describe the role of the preprocessor, compiler and linker in
producing executable code from source code. Discuss how
placing the source code in multiple files is handled using
these tools.
- [5 pts] Show how to, and explain all parts of declaring an array.
Describe what each portion of the declaration does.
- [5 pts] Compare and contrast arrays and structs. (Ie how are they
the same and how are they different)
- [5 pts] Discuss out of bounds array indexing errors. (What this is,
what this can cause to happen)
- [5 pts] Write a routine, which takes an array of integers, and an
integer representing the number of data items in that array as
parameters, returns the average value of the numbers stored
in the array.
- [ 5 pts] Write a routine which given an array of integers between 1 and 50, and an
integer representing the number of data items in that array as
parameters, finds the item that occurs most frequently. Hint:
use a second array.